<?php

function smarty_function_get_subcategory_by_id($params, &$smarty) {
    //Get value from page
    $subcategory_id = $params['subcategory_id'];
    if($subcategory_id){
      //Query data

      //Check exist user & topic
      $pntables = pnDBGetTables();
      $table  = $pntables['icarrent_subcategory'];
      $column = $pntables['icarrent_subcategory_column'];

      $sql = "SELECT
                $table.$column[name]  
              FROM
                $table 
              WHERE
                $table.$column[id] = ".$subcategory_id;

      $column = array("subcategory_name");
      $result = DBUtil::executeSQL($sql);
      $objectArray = DBUtil::marshallObjects ($result, $column);
      $subcategory = $objectArray['0']['subcategory_name'];
    }
    if ($subcategory) {
        $smarty->assign('subcategory_name', $subcategory); 
    } else {
        return "";
    }
}